package com.kapcb.mvc.validator;

import cn.hutool.core.util.PhoneUtil;
import com.kapcb.mvc.annotation.Telephone;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * <a>Title: TelephoneValidator </a>
 * <a>Author: kapcb <a>
 * <a>Description: TelephoneValidator <a>
 *
 * @author Kpacb
 * @version 1.0
 * @date 2024/5/1 15:11
 * @since 1.0
 */
public class TelephoneValidator implements ConstraintValidator<Telephone, String> {

    @Override
    public boolean isValid(String telephone, ConstraintValidatorContext constraintValidatorContext) {
        // 校验手机
        return PhoneUtil.isTel(telephone) || PhoneUtil.isPhone(telephone);
    }

}
